# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Anthony25 <Anthony Ruhier>

_pkgname=Flask-Migrate
pkgname=python-flask-migrate
pkgver=4.0.5
pkgrel=1
pkgdesc='SQLAlchemy database migrations for Flask applications using Alembic..'
url='https://github.com/miguelgrinberg/Flask-Migrate/'
arch=('any')
license=('MIT')
depends=('python' 'python-alembic' 'python-flask' 'python-flask-sqlalchemy')
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-wheel
  python-sphinx
)
checkdepends=(
  python-pytest
)
source=(https://github.com/miguelgrinberg/Flask-Migrate/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('6a4db85626200d05e64eff80666e8ef39c591bdf69f7064912cf04367444a723')
sha512sums=('cdc02e3f567119604e56e9cafed3e7b40e7335d4c3f42cffb26515a4cec12ff34c16f8d5ae036d841cf846985973980d820cdc5d87a99ebf634b3b17becaeb69')

build() {
  cd ${_pkgname}-${pkgver}
  python -m build --wheel --no-isolation
  make -j1 -C docs man text SPHINXBUILD=sphinx-build
}

check() {
  cd ${_pkgname}-${pkgver}
  PYTHONPATH="${PWD}/build/lib" \
    py.test

}

package() {
  cd ${_pkgname}-${pkgver}
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm 644 README.md CHANGES.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 docs/_build/text/* -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 docs/_build/man/flask-migrate.1 "${pkgdir}/usr/share/man/man1/${pkgname}.1"
}

# vim: ts=2 sw=2 et:
